<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html lang="en">

<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <title>LCOV - id:000977,sync:fuzzer2,src:001052.lcov_info_final - test/gmock-1.7.0/src/gmock-cardinalities.cc</title>
  <link rel="stylesheet" type="text/css" href="../../../gcov.css">
</head>

<body>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="title">LCOV - code coverage report</td></tr>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>

    <tr>
      <td width="100%">
        <table cellpadding=1 border=0 width="100%">
          <tr>
            <td width="10%" class="headerItem">Current view:</td>
            <td width="35%" class="headerValue"><a href="../../../index.html">top level</a> - <a href="index.html">test/gmock-1.7.0/src</a> - gmock-cardinalities.cc<span style="font-size: 80%;"> (source / <a href="gmock-cardinalities.cc.func-sort-c.html">functions</a>)</span></td>
            <td width="5%"></td>
            <td width="15%"></td>
            <td width="10%" class="headerCovTableHead">Hit</td>
            <td width="10%" class="headerCovTableHead">Total</td>
            <td width="15%" class="headerCovTableHead">Coverage</td>
          </tr>
          <tr>
            <td class="headerItem">Test:</td>
            <td class="headerValue">id:000977,sync:fuzzer2,src:001052.lcov_info_final</td>
            <td></td>
            <td class="headerItem">Lines:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">56</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr>
            <td class="headerItem">Date:</td>
            <td class="headerValue">2016-03-13 10:42:47</td>
            <td></td>
            <td class="headerItem">Functions:</td>
            <td class="headerCovTableEntry">0</td>
            <td class="headerCovTableEntry">15</td>
            <td class="headerCovTableEntryLo">0.0 %</td>
          </tr>
          <tr><td><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
        </table>
      </td>
    </tr>

    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
  </table>

  <table cellpadding=0 cellspacing=0 border=0>
    <tr>
      <td><br></td>
    </tr>
    <tr>
      <td>
<pre class="sourceHeading">          Line data    Source code</pre>
<pre class="source">
<a name="1"><span class="lineNum">       1 </span>            : // Copyright 2007, Google Inc.</a>
<span class="lineNum">       2 </span>            : // All rights reserved.
<span class="lineNum">       3 </span>            : //
<span class="lineNum">       4 </span>            : // Redistribution and use in source and binary forms, with or without
<span class="lineNum">       5 </span>            : // modification, are permitted provided that the following conditions are
<span class="lineNum">       6 </span>            : // met:
<span class="lineNum">       7 </span>            : //
<span class="lineNum">       8 </span>            : //     * Redistributions of source code must retain the above copyright
<span class="lineNum">       9 </span>            : // notice, this list of conditions and the following disclaimer.
<span class="lineNum">      10 </span>            : //     * Redistributions in binary form must reproduce the above
<span class="lineNum">      11 </span>            : // copyright notice, this list of conditions and the following disclaimer
<span class="lineNum">      12 </span>            : // in the documentation and/or other materials provided with the
<span class="lineNum">      13 </span>            : // distribution.
<span class="lineNum">      14 </span>            : //     * Neither the name of Google Inc. nor the names of its
<span class="lineNum">      15 </span>            : // contributors may be used to endorse or promote products derived from
<span class="lineNum">      16 </span>            : // this software without specific prior written permission.
<span class="lineNum">      17 </span>            : //
<span class="lineNum">      18 </span>            : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
<span class="lineNum">      19 </span>            : // &quot;AS IS&quot; AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
<span class="lineNum">      20 </span>            : // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
<span class="lineNum">      21 </span>            : // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
<span class="lineNum">      22 </span>            : // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
<span class="lineNum">      23 </span>            : // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
<span class="lineNum">      24 </span>            : // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
<span class="lineNum">      25 </span>            : // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
<span class="lineNum">      26 </span>            : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
<span class="lineNum">      27 </span>            : // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
<span class="lineNum">      28 </span>            : // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
<span class="lineNum">      29 </span>            : //
<span class="lineNum">      30 </span>            : // Author: wan@google.com (Zhanyong Wan)
<span class="lineNum">      31 </span>            : 
<span class="lineNum">      32 </span>            : // Google Mock - a framework for writing C++ mock classes.
<span class="lineNum">      33 </span>            : //
<span class="lineNum">      34 </span>            : // This file implements cardinalities.
<span class="lineNum">      35 </span>            : 
<span class="lineNum">      36 </span>            : #include &quot;gmock/gmock-cardinalities.h&quot;
<span class="lineNum">      37 </span>            : 
<span class="lineNum">      38 </span>            : #include &lt;limits.h&gt;
<span class="lineNum">      39 </span>            : #include &lt;ostream&gt;  // NOLINT
<span class="lineNum">      40 </span>            : #include &lt;sstream&gt;
<span class="lineNum">      41 </span>            : #include &lt;string&gt;
<span class="lineNum">      42 </span>            : #include &quot;gmock/internal/gmock-internal-utils.h&quot;
<span class="lineNum">      43 </span>            : #include &quot;gtest/gtest.h&quot;
<span class="lineNum">      44 </span>            : 
<span class="lineNum">      45 </span>            : namespace testing {
<span class="lineNum">      46 </span>            : 
<span class="lineNum">      47 </span>            : namespace {
<a name="48"><span class="lineNum">      48 </span>            : </a>
<span class="lineNum">      49 </span>            : // Implements the Between(m, n) cardinality.
<a name="50"><span class="lineNum">      50 </span><span class="lineNoCov">          0 : class BetweenCardinalityImpl : public CardinalityInterface {</span></a>
<span class="lineNum">      51 </span>            :  public:
<span class="lineNum">      52 </span><span class="lineNoCov">          0 :   BetweenCardinalityImpl(int min, int max)</span>
<span class="lineNum">      53 </span>            :       : min_(min &gt;= 0 ? min : 0),
<span class="lineNum">      54 </span><span class="lineNoCov">          0 :         max_(max &gt;= min_ ? max : min_) {</span>
<span class="lineNum">      55 </span><span class="lineNoCov">          0 :     std::stringstream ss;</span>
<span class="lineNum">      56 </span><span class="lineNoCov">          0 :     if (min &lt; 0) {</span>
<span class="lineNum">      57 </span><span class="lineNoCov">          0 :       ss &lt;&lt; &quot;The invocation lower bound must be &gt;= 0, &quot;</span>
<span class="lineNum">      58 </span><span class="lineNoCov">          0 :          &lt;&lt; &quot;but is actually &quot; &lt;&lt; min &lt;&lt; &quot;.&quot;;</span>
<span class="lineNum">      59 </span><span class="lineNoCov">          0 :       internal::Expect(false, __FILE__, __LINE__, ss.str());</span>
<span class="lineNum">      60 </span><span class="lineNoCov">          0 :     } else if (max &lt; 0) {</span>
<span class="lineNum">      61 </span><span class="lineNoCov">          0 :       ss &lt;&lt; &quot;The invocation upper bound must be &gt;= 0, &quot;</span>
<span class="lineNum">      62 </span><span class="lineNoCov">          0 :          &lt;&lt; &quot;but is actually &quot; &lt;&lt; max &lt;&lt; &quot;.&quot;;</span>
<span class="lineNum">      63 </span><span class="lineNoCov">          0 :       internal::Expect(false, __FILE__, __LINE__, ss.str());</span>
<span class="lineNum">      64 </span><span class="lineNoCov">          0 :     } else if (min &gt; max) {</span>
<span class="lineNum">      65 </span><span class="lineNoCov">          0 :       ss &lt;&lt; &quot;The invocation upper bound (&quot; &lt;&lt; max</span>
<span class="lineNum">      66 </span><span class="lineNoCov">          0 :          &lt;&lt; &quot;) must be &gt;= the invocation lower bound (&quot; &lt;&lt; min</span>
<span class="lineNum">      67 </span><span class="lineNoCov">          0 :          &lt;&lt; &quot;).&quot;;</span>
<span class="lineNum">      68 </span><span class="lineNoCov">          0 :       internal::Expect(false, __FILE__, __LINE__, ss.str());</span>
<span class="lineNum">      69 </span>            :     }
<span class="lineNum">      70 </span><span class="lineNoCov">          0 :   }</span>
<span class="lineNum">      71 </span>            : 
<a name="72"><span class="lineNum">      72 </span>            :   // Conservative estimate on the lower/upper bound of the number of</a>
<a name="73"><span class="lineNum">      73 </span>            :   // calls allowed.</a>
<span class="lineNum">      74 </span><span class="lineNoCov">          0 :   virtual int ConservativeLowerBound() const { return min_; }</span>
<a name="75"><span class="lineNum">      75 </span><span class="lineNoCov">          0 :   virtual int ConservativeUpperBound() const { return max_; }</span></a>
<span class="lineNum">      76 </span>            : 
<span class="lineNum">      77 </span><span class="lineNoCov">          0 :   virtual bool IsSatisfiedByCallCount(int call_count) const {</span>
<span class="lineNum">      78 </span><span class="lineNoCov">          0 :     return min_ &lt;= call_count &amp;&amp; call_count &lt;= max_;</span>
<a name="79"><span class="lineNum">      79 </span>            :   }</a>
<span class="lineNum">      80 </span>            : 
<span class="lineNum">      81 </span><span class="lineNoCov">          0 :   virtual bool IsSaturatedByCallCount(int call_count) const {</span>
<span class="lineNum">      82 </span><span class="lineNoCov">          0 :     return call_count &gt;= max_;</span>
<span class="lineNum">      83 </span>            :   }
<span class="lineNum">      84 </span>            : 
<span class="lineNum">      85 </span>            :   virtual void DescribeTo(::std::ostream* os) const;
<span class="lineNum">      86 </span>            : 
<span class="lineNum">      87 </span>            :  private:
<span class="lineNum">      88 </span>            :   const int min_;
<span class="lineNum">      89 </span>            :   const int max_;
<span class="lineNum">      90 </span>            : 
<span class="lineNum">      91 </span>            :   GTEST_DISALLOW_COPY_AND_ASSIGN_(BetweenCardinalityImpl);
<span class="lineNum">      92 </span>            : };
<a name="93"><span class="lineNum">      93 </span>            : </a>
<span class="lineNum">      94 </span>            : // Formats &quot;n times&quot; in a human-friendly way.
<span class="lineNum">      95 </span><span class="lineNoCov">          0 : inline internal::string FormatTimes(int n) {</span>
<span class="lineNum">      96 </span><span class="lineNoCov">          0 :   if (n == 1) {</span>
<span class="lineNum">      97 </span><span class="lineNoCov">          0 :     return &quot;once&quot;;</span>
<span class="lineNum">      98 </span><span class="lineNoCov">          0 :   } else if (n == 2) {</span>
<span class="lineNum">      99 </span><span class="lineNoCov">          0 :     return &quot;twice&quot;;</span>
<span class="lineNum">     100 </span>            :   } else {
<span class="lineNum">     101 </span><span class="lineNoCov">          0 :     std::stringstream ss;</span>
<span class="lineNum">     102 </span><span class="lineNoCov">          0 :     ss &lt;&lt; n &lt;&lt; &quot; times&quot;;</span>
<span class="lineNum">     103 </span><span class="lineNoCov">          0 :     return ss.str();</span>
<span class="lineNum">     104 </span>            :   }
<span class="lineNum">     105 </span>            : }
<a name="106"><span class="lineNum">     106 </span>            : </a>
<span class="lineNum">     107 </span>            : // Describes the Between(m, n) cardinality in human-friendly text.
<span class="lineNum">     108 </span><span class="lineNoCov">          0 : void BetweenCardinalityImpl::DescribeTo(::std::ostream* os) const {</span>
<span class="lineNum">     109 </span><span class="lineNoCov">          0 :   if (min_ == 0) {</span>
<span class="lineNum">     110 </span><span class="lineNoCov">          0 :     if (max_ == 0) {</span>
<span class="lineNum">     111 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;never called&quot;;</span>
<span class="lineNum">     112 </span><span class="lineNoCov">          0 :     } else if (max_ == INT_MAX) {</span>
<span class="lineNum">     113 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;called any number of times&quot;;</span>
<span class="lineNum">     114 </span>            :     } else {
<span class="lineNum">     115 </span><span class="lineNoCov">          0 :       *os &lt;&lt; &quot;called at most &quot; &lt;&lt; FormatTimes(max_);</span>
<span class="lineNum">     116 </span>            :     }
<span class="lineNum">     117 </span><span class="lineNoCov">          0 :   } else if (min_ == max_) {</span>
<span class="lineNum">     118 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;called &quot; &lt;&lt; FormatTimes(min_);</span>
<span class="lineNum">     119 </span><span class="lineNoCov">          0 :   } else if (max_ == INT_MAX) {</span>
<span class="lineNum">     120 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;called at least &quot; &lt;&lt; FormatTimes(min_);</span>
<span class="lineNum">     121 </span>            :   } else {
<span class="lineNum">     122 </span>            :     // 0 &lt; min_ &lt; max_ &lt; INT_MAX
<span class="lineNum">     123 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;called between &quot; &lt;&lt; min_ &lt;&lt; &quot; and &quot; &lt;&lt; max_ &lt;&lt; &quot; times&quot;;</span>
<span class="lineNum">     124 </span>            :   }
<span class="lineNum">     125 </span><span class="lineNoCov">          0 : }</span>
<span class="lineNum">     126 </span>            : 
<span class="lineNum">     127 </span>            : }  // Unnamed namespace
<a name="128"><span class="lineNum">     128 </span>            : </a>
<span class="lineNum">     129 </span>            : // Describes the given call count to an ostream.
<span class="lineNum">     130 </span><span class="lineNoCov">          0 : void Cardinality::DescribeActualCallCountTo(int actual_call_count,</span>
<span class="lineNum">     131 </span>            :                                             ::std::ostream* os) {
<span class="lineNum">     132 </span><span class="lineNoCov">          0 :   if (actual_call_count &gt; 0) {</span>
<span class="lineNum">     133 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;called &quot; &lt;&lt; FormatTimes(actual_call_count);</span>
<span class="lineNum">     134 </span>            :   } else {
<span class="lineNum">     135 </span><span class="lineNoCov">          0 :     *os &lt;&lt; &quot;never called&quot;;</span>
<span class="lineNum">     136 </span>            :   }
<span class="lineNum">     137 </span><span class="lineNoCov">          0 : }</span>
<a name="138"><span class="lineNum">     138 </span>            : </a>
<span class="lineNum">     139 </span>            : // Creates a cardinality that allows at least n calls.
<span class="lineNum">     140 </span><span class="lineNoCov">          0 : GTEST_API_ Cardinality AtLeast(int n) { return Between(n, INT_MAX); }</span>
<a name="141"><span class="lineNum">     141 </span>            : </a>
<span class="lineNum">     142 </span>            : // Creates a cardinality that allows at most n calls.
<span class="lineNum">     143 </span><span class="lineNoCov">          0 : GTEST_API_ Cardinality AtMost(int n) { return Between(0, n); }</span>
<a name="144"><span class="lineNum">     144 </span>            : </a>
<span class="lineNum">     145 </span>            : // Creates a cardinality that allows any number of calls.
<span class="lineNum">     146 </span><span class="lineNoCov">          0 : GTEST_API_ Cardinality AnyNumber() { return AtLeast(0); }</span>
<a name="147"><span class="lineNum">     147 </span>            : </a>
<span class="lineNum">     148 </span>            : // Creates a cardinality that allows between min and max calls.
<span class="lineNum">     149 </span><span class="lineNoCov">          0 : GTEST_API_ Cardinality Between(int min, int max) {</span>
<span class="lineNum">     150 </span><span class="lineNoCov">          0 :   return Cardinality(new BetweenCardinalityImpl(min, max));</span>
<span class="lineNum">     151 </span>            : }
<a name="152"><span class="lineNum">     152 </span>            : </a>
<span class="lineNum">     153 </span>            : // Creates a cardinality that allows exactly n calls.
<span class="lineNum">     154 </span><span class="lineNoCov">          0 : GTEST_API_ Cardinality Exactly(int n) { return Between(n, n); }</span>
<span class="lineNum">     155 </span>            : 
<span class="lineNum">     156 </span>            : }  // namespace testing
</pre>
      </td>
    </tr>
  </table>
  <br>

  <table width="100%" border=0 cellspacing=0 cellpadding=0>
    <tr><td class="ruler"><img src="../../../glass.png" width=3 height=3 alt=""></td></tr>
    <tr><td class="versionInfo">Generated by: <a href="http://ltp.sourceforge.net/coverage/lcov.php" target="_parent">LCOV version 1.11</a></td></tr>
  </table>
  <br>

</body>
</html>
